﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace NetMicro.Applications.Request
{
    /// <summary>
    /// 分页基类
    /// </summary>
    public class PagingRequest : RequestBase
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;
        /// <summary>
        /// 每页显示的条数
        /// </summary>
        public int PageSize { get; set; } = 10;

        public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            base.Validate(validationContext);
            PageSize = PageSize == 0 ? 10 : PageSize > 10000 ? 10 : PageSize;
            PageIndex = PageIndex == 0 ? 1 : PageIndex;
            yield break;
        }

    }



}
